<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
  <title><spring:message code="activiti.task.title" /></title>
  <meta name="decorator" content="list"/>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script type="text/javascript" src="${staticPath }/uadmin/js/public-add.js"></script>
  <html:css  name="iCheck,Validform,jquery-ztree,easy-ui"/>
  <html:js  name="iCheck,Validform,jquery-ztree,easy-ui,public-js"/>
  <style type="text/css">.row{margin:0;}</style>
  <script type="text/javascript" src="${staticPath }/uadmin/js/public-add.js"></script>
  <script type="text/javascript" src="${staticPath}/common/js/ztree.js"></script>
  <script type="text/javascript" src="${staticPath}/modules/activiti/js/workflow.js"></script>
  <script type="text/javascript" src="${staticPath}/common/js/window.js"></script>
</head>
<body title="<spring:message code="activiti.task.title" />">
<div class="easyui-layout" fit="true" id="cc" style="width:100%;">
	<div data-options="region:'west',split:true" style="width:15%;" title="流程类型">
		 <div class="zTreeDemoBackground left">
			<ul id="ztree" class="ztree"></ul>
		</div>
	</div>
	<div data-options="region:'center'" title="运行任务">
		<grid:grid id="activitiModelId" sortname="t.id_" url="${adminPath}/activiti/flow/task/ajaxList" gridSetting="{loadComplete:onloadFun}">
			<grid:column label="activiti.task.id" hidden="true" name="id" width="100"/>
			<grid:column label="activiti.execution.id" hidden="true" name="executionId" />
			<grid:column label="sys.common.opt"  name="opt" formatter="button" width="220"/>
			<grid:column label="activiti.procinst.id" width="60" name="procInstId" />
			<grid:column label="activiti.procdef.id"  name="procDefId" />
			<grid:column label="activiti.task.process.name" name="flowName" />
			<grid:column label="activiti.task.activiti.name"  name="name" />
		    <grid:column label="activiti.task.taskdefkey"  name="taskDefKey" />
		    <grid:column label="activiti.task.assignee" width="80" name="assigneeName" />
		    <grid:column label="activiti.task.starttime" width="80" name="createTime" formatter="date" dateformat="yyyy-MM-dd"/>
		    <grid:column label="activiti.task.duedate" width="80" name="dueDate" formatter="date" dateformat="yyyy-MM-dd"/>
		    <grid:column label="activiti.task.suspension.state" width="60" name="suspensionState" dict="lcgq"/>
		    <grid:column label="activiti.task.description"  name="description"  />
			<grid:toolbar title="转办" onclick="transTask()" btnclass="btn-fa-upload" icon="fa-share-square-o"/>
			<grid:toolbar title="跳转" onclick="skipTask()" btnclass="btn-fa-sign-in" icon="fa-repeat"/>
			<grid:button groupname="opt" function="rowDialogDetailRefresh" title="activiti.task.flow.chart" outclass="btn-fa-choose"  innerclass="fa-eye" url="${adminPath}/activiti/flow/flowchart?taskId=\"+row.id+\"" winwidth="60%" winheight="70%" />
			<grid:button groupname="opt" function="rowDialogDetailRefresh" title="activiti.task.approval.record" outclass="btn-info"  innerclass="fa-video-camera" url="${adminPath}/activiti/flow/histaskComment?taskId=\"+row.id+\"" winwidth="60%" winheight="70%"/>
			<grid:button groupname="opt" exp="row.suspensionState==1" function="rowConfirm" title="activiti.hangup" tipMsg="你确定要挂起该任务吗?" outclass="btn-fa-bar-chart" innerclass="fa-ban" url="${adminPath}/activiti/flow/suspendProcessInstance?taskId={id}"/>
			<grid:button groupname="opt" exp="row.suspensionState==2" function="rowConfirm" title="activiti.activate" tipMsg="你确定要激活该任务吗?" outclass="btn-primary" innerclass="fa-hourglass-start" url="${adminPath}/activiti/flow/activateProcessInstance?taskId={id}"/>
			<grid:button groupname="opt" function="rowConfirm" title="activiti.closed" tipMsg="你确定要关闭该任务吗?" outclass="btn-fa-close" innerclass="fa-times" url="${adminPath}/activiti/flow/endProcess?taskId={id}"/>
			<grid:toolbar  function="search"  />
		</grid:grid>
	</div>
</div>

<script type="text/javascript">

var gridId = 'activitiModelIdGrid';
var treeObj = null;
var nodeId = null;

/**
 * @description 初始化加载js.<br>
 * @date 2018/8/27.<br>
 * @author zcg .<br>
 */
$(function(){
	var ztreeList = '${ztreeList}';
	ztreeList = $.parseJSON(ztreeList);
	treeObj = $.fn.zTree.init($("#ztree"), setting, ztreeList);
});
 
/**
 * @description 左侧树的相关参数设置.<br>
 * @date 2018/2/24.<br>
 * @author zcg .<br>
 */ 
var setting = {
	callback: {
		onClick: zTreeOnClick
	}
}
 
/**
 * @description 点击左侧的树,触发搜索.<br>
 * @date 2018/2/24.<br>
 * @author zcg .<br>
 */
function zTreeOnClick(event, treeId, treeNode){
	nodeId = treeNode.id;
	search(gridId,{nodeId:nodeId});
}

/**
 * @description 转办任务.<br> 
 * @date 2017/12/26 .<br>
 * @author zcg .<br>
 */
function transTask(){
	var basePath = '${adminPath}';
	var gridId = 'activitiModelIdGrid';
	var rows =$("#"+gridId).jqGrid('getGridParam','selarrrow');
	var rowData= $("#"+gridId).jqGrid('getGridParam','selrow');
	if(rows.length<2&&rowData){
		transferTask(basePath,rowData);
	}else{
		layer.alert('请选择一条数据', {icon: 0, title:'警告'});
	}	
}
 
 /**
  * @description 跳转任务.<br> 
  * @date 2017/12/26 .<br>
  * @author zcg .<br>
  */
 function skipTask(){
 	var basePath = '${adminPath}';
 	var gridId = 'activitiModelIdGrid';
 	var rows =$("#"+gridId).jqGrid('getGridParam','selarrrow');
 	var rowData= $("#"+gridId).jqGrid('getGridParam','selrow');
 	if(rows.length<2&&rowData){
 		transferTask(basePath,rowData);
 	}else{
 		layer.alert('请选择一条数据', {icon: 0, title:'警告'});
 	}	
 }


</script>
